/*******************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.        */
/*                                                                 */
/*  NAME      = t_rtsp_core_add_unfinshed_fragmented_packets.c     */
/*  NOTE      =                                                    */
/*  DATE      = 2016/02/04 by songbb                               */
/*******************************************************************/

#include <CUnit/Basic.h>
#include <stdlib.h>

#include "frcomm.h"
#include "frmem.h"

#include "../../../src/module/rtsp/config.h"
#include "../test_rtsp_comm.h"
#include <rtsp/rtsp_core.h>
#include <rtsp/rtsp_header.h>
#include <rtsp/rtsp_comm.h>
#include <rtsp/rtsp_packet.h>
#include <frct_comm.h>

extern void __rtsp_add_error_nums(L7session_rtsp *p_st_sess);

static int __suite_init(void)
{
    return 0;
}

static int __suite_cleanup(void)
{
    return 0;
}

static void __case1(void)
{
    Conntrack *p_st_conn = NULL;
    CU_ASSERT_EQUAL(test_rtsp_create_ct(&p_st_conn, TEST_RTSP_SRC_IP, TEST_RTSP_DST_IP, TEST_RTSP_SRC_PORT, TEST_RTSP_DST_PORT), FR_SUCC);

    L7_session *p_st_session = frct_get_session(p_st_conn);

    L7session_rtsp_private *p_st_session_private = (L7session_rtsp_private *) frct_get_session_private(p_st_session);
    L7session_rtsp *p_st_sess = p_st_session_private->p_st_sess;

    rtsp_core_add_unfinshed_fragmented_packets(p_st_sess);
    rtsp_core_add_unfinshed_fragmented_packets(p_st_sess);
    rtsp_core_add_unfinshed_fragmented_packets(p_st_sess);

    CU_ASSERT_EQUAL(p_st_sess->ull_unfinshed_fragmented_packets, 3L);

    test_rtsp_destroy_ct(&p_st_conn);
    CU_ASSERT_PTR_NULL(p_st_conn);
}

int add_suite_rtsp_core_add_unfinshed_fragmented_packets(void)
{
    CU_pSuite pSuite = NULL;

    if ((pSuite = CU_add_suite(MODULE_NAME" rtsp_core_add_unfinshed_fragmented_packets()", __suite_init, __suite_cleanup)) == NULL)
        return FR_FAIL;

    if (CU_add_test(pSuite, "case1", __case1) == NULL)
        return FR_FAIL;

    return FR_SUCC;
}
